<?php
include("include/conn.php");
require('include/Smarty/libs/Smarty.class.php');

$fine = 0;
$amount = 0;
echo $selectVeepariBook    = "SELECT fine,amount,CrDr,vepaariBookDate FROM vepaaribook
                          WHERE partyId = ".$_POST['partyId']."
                            AND vepaariBookDate <= '".date("Y-m-d")."'
                       ORDER BY vepaariBookDate, vepaaribookId";
$selectVeepariBookRes = mysql_query($selectVeepariBook);
while($row = mysql_fetch_assoc($selectVeepariBookRes))
{
	if($row['CrDr'] == "Dr")
	{
     $fine   += $row['fine'];
     $amount += $row['amount'];
    
	}
	else
	{
    $fine    -= $row['fine'];
    $amount  -= $row['amount'];
   
	}
}
echo $billBook = "SELECT totalFine,totalAmount FROM billbook
              WHERE partyId = ".$_POST['partyId']."
              ORDER BY billBookId";
 $billBookRes = mysql_query($billBook);
while($billBook = mysql_fetch_assoc($billBookRes))
{
	$fine   += $billBook['totalFine'];
  $amount += $billBook['totalAmount'];
}

echo number_format($fine, 0, '.', '').",".number_format($amount, 0, '.', '');
//echo "<b>Prev. Fine</b> <input type='text' name='partyFine' id='partyFine' value='".number_format($fine, 2, '.', '')."'/> ";
//echo "<b>Prev. Amount</b> <input type='text' name='partyAmount' id='partyAmount' value='".number_format($amount, 2, '.', '')."'/>";
?>